#include <bits/stdc++.h>
using namespace std;
#define pb push_back

const int N=5e5+5;
int n,m,ans=0;
vector<int> G[N];
bool vis[N];

namespace Lian{
  bool chk(){
  	for(int i=1;i<=n;i++) if((int)G[i].size()>2) return false;
  	return true; 
  }
}

bool dfs(int u,int pre,int len,int cnt){
  cnt+=vis[u];
  if(len==m) return cnt==1;
  for(int v:G[u]) if(v!=pre&&!dfs(v,u,len+1,cnt)) return false;
  return true;
}

bool chk(int S){
  for(int i=1;i<=n;i++) vis[i]=(S>>(i-1)&1);
  for(int i=1;i<=n;i++) if(!dfs(i,0,1,0)) return false;
  return true;
}

int main(){
  freopen("life.in","r",stdin);
  freopen("life.out","w",stdout);
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>n>>m;
  for(int i=1,u,v;i<n;i++) cin>>u>>v,G[u].pb(v),G[v].pb(u);
  if(Lian::chk()) cout<<"YES\n"<<m<<"\n",exit(0);

  for(int S=0;S<(1<<n);S++) ans+=chk(S);
  if(!ans) cout<<"NO\n";
  else cout<<"YES\n";
  cout<<ans<<'\n';
  return 0;
}